package com.CTAtracker.android.Activities;

import android.app.ActionBar;
import android.app.Activity;
import android.app.Fragment;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.CTAtracker.android.R;
import com.CTAtracker.android.Fragments.SearchStationFragment;

public class LineActivity extends Activity {

	private int _idLine; 

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// set the current layout
		setContentView(R.layout.line_activity);
		// set the current Fragment
		_idLine = getIntent().getExtras().getInt("idLine");
		
		// Inflate Menu
        ActionBar actionbar = getActionBar();
        actionbar.setDisplayShowTitleEnabled(false);
        actionbar.setDisplayShowCustomEnabled(true);
        actionbar.setDisplayShowHomeEnabled(false);
        actionbar.setCustomView(R.layout.actionbar_back);

        ImageView back_button = (ImageView) findViewById(R.id.back_button);
        back_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
		
		SearchStationFragment searchStationFragment = new SearchStationFragment(); 
		searchStationFragment.setIdLine(_idLine);
		this.replaceContent(searchStationFragment);
	}

	@Override
	protected void onResume() {
		super.onResume();
	}

	/**
	 * This method replace the current fragment
	 * @param frag the new fragment
	 */
	public void replaceContent(Fragment frag) {
		getFragmentManager()
		.beginTransaction()
		.replace(R.id.lineActivity, frag)
		.commit();
	}
}
